#include "mainwidget.h"
#include "ui_mainwidget.h"

//单独设置mainWidget类，实现stackLayout布局实现界面切换
mainWidget::mainWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::mainWidget)
{
    ui->setupUi(this);
    menu=new Menu;
    set_ad=new Set_ad;
    ad=new Ad;
    enter_st=new Enter_st;
    enter_ad=new Enter_ad;
    gpa=new GPA;
    stackLayout=new QStackedLayout;

    //对stackLayout添加界面,索引从0开始
    stackLayout->addWidget(menu);//display(0)
    stackLayout->addWidget(set_ad);//display(1)
    stackLayout->addWidget(ad);//display(2)
    stackLayout->addWidget(enter_st);//display(3)
    stackLayout->addWidget(enter_ad);//display(4)
    stackLayout->addWidget(gpa);//display(5)


    setLayout(stackLayout);

    //把display信号与设置界面索引函数的槽连接
    connect(menu,&Menu::display,stackLayout,&QStackedLayout::setCurrentIndex);
    connect(set_ad,&Set_ad::display,stackLayout,&QStackedLayout::setCurrentIndex);
    connect(ad,&Ad::display,stackLayout,&QStackedLayout::setCurrentIndex);
    connect(enter_st,&Enter_st::display,stackLayout,&QStackedLayout::setCurrentIndex);
    connect(enter_ad,&Enter_ad::display,stackLayout,&QStackedLayout::setCurrentIndex);
    connect(gpa,&GPA::display,stackLayout,&QStackedLayout::setCurrentIndex);


}

mainWidget::~mainWidget()
{
    delete ui;
}

